﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterClinicaSanPablo.Master" AutoEventWireup="true" EnableEventValidation="false"
    CodeBehind="BusquedaSolicitud.aspx.cs" Inherits="ClinicaSanPablo.BusquedaSolicitud" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

            $(document).ready(function () {
                $("#txtFecha").datepicker();
            });

            $('#btnBuscarSolicitud').click(function () {
                div = document.getElementById('oculta1');
                div.style.display = "block";
                $("#grdListSolicitudes").trigger("reloadGrid");
                return false;
            });


            $("#grdListSolicitudes").jqGrid({
                url: "BusSolicitudes.aspx",
                datatype: 'json',
                type: 'GET',
                colNames: ['Código', 'Titulo de Solicitud', 'Registrado Por', 'Fecha'],
                colModel: [
                    { name: 'Id', index: 'Id', align: 'center', width: 100, sortable: false },
                    { name: 'TituloSolicitud', index: 'TituloSolicitud', align: 'center', width: 500, sortable: false },
                    { name: 'RegistradoPor', index: 'RegistradoPor', align: 'center', width: 140, sortable: false },
                    { name: 'Fecha', index: 'Fecha', align: 'center', width: 140, sortable: false },
                    ],
                pager: jQuery('#grdPagerSolicitudes'),
                rowNum: 20,
                rowList: [20, 50, 100],
                sortname: 'Id',
                sortorder: 'desc',
                postData: {
                    codigoSolicitud: function () { return $("#txtCodigo").val(); },
                    descripcionSolicitud: function () { return $("#txtDescripcion").val(); },
                    estadoSolicitud: function () { return $("#cmbEstado").val(); },
                    usuarioRegistro: function () { return $("#cmbUsuarioRegistro").val(); },
                    areaRegistro: function () { return $("#cmbAreaRegistro").val(); },
                    areaInvolucrada: function () { return $("#cmbAreaInvolucrada").val(); },
                    servicioInvolucrado: function () { return $("#cmbServicio").val(); },
                    formaPresentacion: function () { return $("#cmbPresentacion").val(); },
                    fecha: function () { return $("#txtFecha").val(); }
                }
            });

            $.ajax({
                type: "POST",
                url: "BusquedaSolicitud.aspx/ComboEstadoSolicitud",
                data: {},
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i].CodEstado;
                        var text = models[i].DesEstado;
                        $("#cmbEstado").get(0).options[$("#cmbEstado").get(0).options.length] = new Option(text, val);
                    }
                },
                error: function (response) {
                    if (response.length != 0)
                        alert(response);
                }
            });

            $.ajax({
                type: "POST",
                url: "BusquedaSolicitud.aspx/ComboUsuario",
                data: {},
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i].CodUsuario;
                        var text = models[i].NombresUsuario;
                        $("#cmbUsuarioRegistro").get(0).options[$("#cmbUsuarioRegistro").get(0).options.length] = new Option(text, val);
                    }
                },
                error: function (response) {
                    if (response.length != 0)
                        alert(response);
                }
            });

            $.ajax({
                type: "POST",
                url: "BusquedaSolicitud.aspx/ComboArea",
                data: {},
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i].CodArea;
                        var text = models[i].DesArea;
                        $("#cmbAreaRegistro").get(0).options[$("#cmbAreaRegistro").get(0).options.length] = new Option(text, val);
                    }
                },
                error: function (response) {
                    if (response.length != 0)
                        alert(response);
                }
            });

            $.ajax({
                type: "POST",
                url: "BusquedaSolicitud.aspx/ComboArea",
                data: {},
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i].CodArea;
                        var text = models[i].DesArea;
                        $("#cmbAreaInvolucrada").get(0).options[$("#cmbAreaInvolucrada").get(0).options.length] = new Option(text, val);
                    }
                },
                error: function (response) {
                    if (response.length != 0)
                        alert(response);
                }
            });

            $.ajax({
                type: "POST",
                url: "BusquedaSolicitud.aspx/ComboServicio",
                data: {},
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i].CodServicio;
                        var text = models[i].DesServicio;
                        $("#cmbServicio").get(0).options[$("#cmbServicio").get(0).options.length] = new Option(text, val);
                    }
                },
                error: function (response) {
                    if (response.length != 0)
                        alert(response);
                }
            });

            $.ajax({
                type: "POST",
                url: "BusquedaSolicitud.aspx/ComboPresentacion",
                data: {},
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var models = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                    for (var i = 0; i < models.length; i++) {
                        var val = models[i].CodPresentacion;
                        var text = models[i].DesPresentacion;
                        $("#cmbPresentacion").get(0).options[$("#cmbPresentacion").get(0).options.length] = new Option(text, val);
                    }
                },
                error: function (response) {
                    if (response.length != 0)
                        alert(response);
                }
            });
            $('.csAlfanumerico').alphanumeric({ allow: " .,-" });
            $('.csNumerico').numeric({ allow: "" });
        });
       
    </script>
    <style type="text/css">
        .style1
        {
            width: 197px;
        }
        .style2
        {
            width: 190px;
        }
        .style3
        {
            width: 187px;
        }
        .style5
        {
            width: 187px;
            height: 21px;
        }
        .style6
        {
            height: 140px;
        }
        .style9
        {
            width: 274px;
        }
        .style10
        {
            width: 274px;
            height: 21px;
        }
        .style11
        {
            width: 268px;
        }
        .style12
        {
            width: 268px;
            height: 21px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="master" runat="server">
    <form id="registroSugerencia" runat="server">
    <div class="cuerpo">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td colspan="3">
                    <img src="images/caja_main01.gif" width="973" height="13" />
                </td>
            </tr>
            <tr>
                <td width="7" background="images/caja_main02.gif">
                    &nbsp;
                </td>
                <td class="info" valign="top">
                    <h1>
                        Consulta de <strong>Solicitudes</strong></h1>
                    <div class="content" style="margin-bottom: 10px;">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="TablaStyle">
                            <tr>
                                <td width="6">
                                </td>
                                <td>
                                </td>
                                <td width="6">
                                </td>
                            </tr>
                            <tr>
                                <td width="6" class="style6">
                                </td>
                                <td bgcolor="#eeeeee" class="style6">
                                    <h2>
                                        Búsqueda de Solicitud</h2>
                                    <table width="95%" border="0" align="center" cellpadding="2" cellspacing="1" style="height: 102px">
                                        <tr>
                                            <td class="style11">
                                                Codigo:
                                            </td>
                                            <td class="style9">
                                                Descripcion:
                                            </td>
                                            <td class="style3">
                                                Estado:
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:TextBox ID="txtCodigo" runat="server" CssClass="frm csNumerico" Width="96px"></asp:TextBox>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="txtDescripcion" runat="server" CssClass="frm csAlfanumerico" Width="250px"></asp:TextBox>
                                            </td>
                                            <td class="style3">
                                                <asp:DropDownList ID="cmbEstado" runat="server" Height="22px" Width="200px">
                                                    <asp:ListItem Text="---Seleccione un Estado---" Value="" Selected="True"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="style2">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style12">
                                                Usuario Registro:
                                            </td>
                                            <td class="style10">
                                                Area Registro:
                                            </td>
                                            <td class="style3">
                                                Area Involucrada:
                                            </td>
                                            <td class="style5">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:DropDownList ID="cmbUsuarioRegistro" runat="server" Height="22px" Width="200px">
                                                    <asp:ListItem Text="---Seleccione un Usuario---" Value="" Selected="True"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="style9">
                                                <asp:DropDownList ID="cmbAreaRegistro" runat="server" Height="22px" Width="200px">
                                                    <asp:ListItem Text="---Seleccione una Área---" Value="" Selected="True"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="style3">
                                                <asp:DropDownList ID="cmbAreaInvolucrada" runat="server" Height="22px" Width="200px">
                                                    <asp:ListItem Text="---Seleccione una Área---" Value="" Selected="True"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="style1">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                Servicio Involucrado:
                                            </td>
                                            <td class="style9">
                                                Forma de Presentacion:
                                            </td>
                                            <td class="style3">
                                                Fecha Registro:
                                            </td>
                                            <td>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:DropDownList ID="cmbServicio" runat="server" Height="22px" Width="200px">
                                                    <asp:ListItem Text="---Seleccione un Servicio---" Value="" Selected="True"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="style9">
                                                <asp:DropDownList ID="cmbPresentacion" runat="server" Height="22px" Width="200px">
                                                    <asp:ListItem Text="---Seleccione Presentacion---" Value="" Selected="True"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td class="style3">
                                                <asp:TextBox ID="txtFecha" runat="server" CssClass="frm" Width="96px"></asp:TextBox>
                                            </td>
                                            <td class="style1">
                                                <button id="btnBuscarSolicitud" class="submitBtn">
                                                    <span>Buscar</span></button>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="6" class="style6">
                                </td>
                            </tr>
                            <tr>
                                <td width="6">
                                </td>
                                <td >
                                </td>
                                <td width="6">
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="oculta1" style="display: nones;">
                        <div class="content" id="page-2">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="TablaStyle">
                                <tr>
                                    <td width="6">
                                    </td>
                                    <td>
                                    </td>
                                    <td width="6">
                                    </td>
                                </tr>
                                <tr>
                                    <td width="6">
                                        &nbsp;
                                    </td>
                                    <td bgcolor="#eeeeee">
                                        <h2>
                                            Resultado:</h2>
                                        <div style="width: 100%;" id="asd">
                                            <table id="grdListSolicitudes">
                                            </table>
                                        </div>
                                        <div id="grdPagerSolicitudes">
                                        </div>
                                        <br />
                                    </td>
                                    <td width="6">
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td width="6">
                                    </td>
                                    <td>
                                    </td>
                                    <td width="6">
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <asp:GridView ID="GridView1" runat="server" Visible="False" AutoGenerateColumns="False">
                            <Columns>
                                <asp:BoundField DataField="CodSolicitud" HeaderText="Código" />
                                <asp:BoundField DataField="DesSolicitud" HeaderText="Descripción" />
                                <asp:BoundField DataField="Usuario" HeaderText="Usuario" />
                                <asp:BoundField DataField="FechaSolicitud" HeaderText="Fecha de Solicitud" />
                            </Columns>
                        </asp:GridView>
                        <p align="center">
                            <asp:Button ID="btnExportarExcel" runat="server" Text="Exportar XLS" class="submitBtn"
                                OnClick="btnExportarExcel_Click" Width="84px" />
                            <asp:Button ID="btnExportarPDF" runat="server" Text="Exportar PDF" class="submitBtn"
                                Width="84px" OnClick="btnExportarPDF_Click" />
                            <div style="display: none">
                              <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
                                <rsweb:reportviewer id="ReportViewer1" runat="server" height="506px" sizetoreportcontent="True"
                                    documentmapcollapsed="True" showbackbutton="True" exportcontentdisposition="AlwaysInline"
                                    width="825px">
        </rsweb:reportviewer>
                            </div>
                        </p>
                    </div>
                </td>
                <td width="7" background="images/caja_main03.gif">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <img src="images/caja_main04.gif" width="973" height="13" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</asp:Content>
